package com.kunpeng.weibo.weixin.api;

import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.SendMessageToWX;
import com.tencent.mm.sdk.openapi.WXMediaMessage;
import com.tencent.mm.sdk.openapi.WXVideoObject;

public class SendVideo_API extends Request_API {

	public SendVideo_API(IWXAPI api) {
		super(api);
	}

	/**
	 * 分享视频
	 * 
	 * @param url
	 * @param title 标题
	 * @param desc 描述
	 * @param thumb 缩略图
	 */
	public void sendVideoWithUrl(String url, String title, String desc) throws IllegalArgumentException {
		if (url == null || url.equals("") || !url.startsWith("http")) {
			throw new IllegalArgumentException();
		}
		WXVideoObject video = new WXVideoObject();
		video.videoUrl = url;

		WXMediaMessage msg = new WXMediaMessage();
		if (title != null) {
			msg.title = title;
		}
		if (desc != null) {
			msg.description = desc;
		}
		SendMessageToWX.Req req = new SendMessageToWX.Req();
		req.transaction = buildTransaction("video");
		req.message = msg;
		mWeixinApi.sendReq(req);
	}

	/**
	 * 分享低带宽视频
	 * 
	 * @param url
	 * @param title
	 * @param desc
	 * @param thumb
	 * @throws IllegalArgumentException
	 */
	public void sendVideoWithLowBandUrl(String url, String title, String desc) throws IllegalArgumentException {
		if (url == null || url.equals("") || !url.startsWith("http")) {
			throw new IllegalArgumentException();
		}
		WXVideoObject video = new WXVideoObject();
		video.videoLowBandUrl = url;

		WXMediaMessage msg = new WXMediaMessage();
		if (title != null) {
			msg.title = title;
		}
		if (desc != null) {
			msg.description = desc;
		}

		SendMessageToWX.Req req = new SendMessageToWX.Req();
		req.transaction = buildTransaction("video");
		req.message = msg;
		mWeixinApi.sendReq(req);
	}
}
